package com.hospital.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 自定义配置类
 * @Configuration 此注解一定得写，不然跨域失效！！！
 * @author coder_zzm
 * @date 2022/5/8 22:33
 */
@Configuration
public class MyServletMvcConfiguration implements WebMvcConfigurer {

    /**
     * 跨域的配置
     * @param registry 参数名
     */
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowCredentials(true)
                .allowedMethods("GET", "POST", "DELETE", "PUT", "OPTIONS", "HEAD")
                .allowedOrigins("http://127.0.0.1:8848");
    }
}
